package com.cg.controller;

import com.cg.dto.OrderDto;
import com.cg.dto.OrderListPageDto;
import com.cg.dto.Result;
import com.cg.dto.ResultUtils;
import com.cg.service.OrderService;
import com.cg.vo.OrderDetailVo;
import com.cg.vo.OrderListVo;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * (Order)表控制层
 *
 * @author chengong
 * @since 2024-01-12 10:09:49
 */
@RestController
@RequestMapping("/order")
public class OrderController {
    /**
     * 服务对象
     */
    @Resource
    private OrderService orderService;

    /**
     * 患者预约
     */
    @PostMapping("/createOrder")
    public Result createOrder(@RequestBody OrderDto orderDto){
        return orderService.createOrder(orderDto);
    }


    /**
     * 查询预约成功通知列表
     */
    @PostMapping("/orderList")
    public Result<Map<String,Object>> orderListByPatientId(@RequestBody OrderListPageDto orderListPageDto) {
        PageInfo<OrderListVo> pageInfo = orderService.orderListByPatientId(orderListPageDto);
        Map<String,Object> map = new HashMap<>();
        map.put("pageInfo",pageInfo);
        return ResultUtils.returnDataSuccess(map);
    }


    /**
     * 根据orderNum查询详情
     */
    @GetMapping("/queryOrderDetailByOrderNum")
    public Result<OrderDetailVo> queryOrderDetailByOrderNum(@RequestParam("orderNum") String orderNum){
        OrderDetailVo orderDetailVo = orderService.queryOrderDetailByOrderNum(orderNum);
        return ResultUtils.returnDataSuccess(orderDetailVo);
    }

}

